#include "head.h"

void alter_flighttype(F_node * ptr)
{
    printf("请输入新机型\n");
    scanf("%s", ptr->data.flighttype);
    printf("机型修改成功\n");
    sleep(1);
    return ;
}
void alter_startcity(F_node * ptr)
{
    printf("请输入新起点站\n");
    scanf("%s", ptr->data.startcity);
    printf("起点站修改成功\n");
    sleep(1);
    return ;
}
void alter_arrivecity(F_node * ptr)
{
    printf("请输入新终点站\n");
    scanf("%s", ptr->data.arrivecity);
    printf("终点站修改成功\n");
    sleep(1);
    return ;
}
void alter_flytime(F_node * ptr)
{
    printf("请输入新起飞时间\n");
    scanf("%d %d", &ptr->data.starttime[0], &ptr->data.starttime[1]);
    printf("请输入新降落时间\n");
    scanf("%d %d", &ptr->data.arrivetime[0], &ptr->data.arrivetime[1]);
    printf("请输入新飞行时间\n");
    scanf("%s", ptr->data.flytime);
    printf("飞行时间修改成功\n");
    sleep(1);
    return ;
}
void alter_value(F_node * ptr)
{
    printf("请输入新机票价\n");
    scanf("%d", &ptr->data.value);
    printf("机票价修改成功\n");
    sleep(1);
    return ;
}
void alter_maxNUM(F_node * ptr)
{
    printf("请输入新载客量数\n");
    scanf("%d", &ptr->data.maxNUM);
    printf("载客量修改成功\n");
    sleep(1);
    return ;
}
void alter_leftbuyersa(F_node * ptr)
{
    printf("请输入新剩余可买票数\n");
    scanf("%d", &ptr->data.leftbuyersa);
    printf("剩余可买票数修改成功\n");
    sleep(1);
    return ;
}
void alter_whetherfly(F_node * ptr)
{
    printf("请输入最新的起飞情况\n");
    scanf("%c", &ptr->data.whetherfly);
    printf("是否在飞修改成功\n");
    sleep(1);
    return ;
}
void alter_name(U_node*ptr,FlightSystem *Flight_list)
{
    printf("请输入新用户名\n");
    char name[16];
    scanf("%s", name);
    U_node * ptr_1;
    U_node * ptr_2;
    U_node * ptr_3;
    U_node * ptr_4;
    U_node * ptr_5;
    switch (ptr->data.grade)
    {
        case 1:
            ptr_1 = S_List_find_name(Flight_list->ADMIN_USER,ptr->data.name);
            strcpy(ptr_1->data.name, name);
            S_List_File_print(Flight_list->ADMIN_USER, ADMIN_FILE);
            break;
        case 2:
            ptr_2 = S_List_find_name(Flight_list->REGULAR_USER,ptr->data.name);
            strcpy(ptr_2->data.name, name);
            S_List_File_print(Flight_list->REGULAR_USER, REGULAR_FILE);
            break;
        case 3:
            ptr_3 = S_List_find_name(Flight_list->SILVER_USER,ptr->data.name);
            strcpy(ptr_3->data.name, name);
            S_List_File_print(Flight_list->SILVER_USER, SILVER_FILE);
            break;
        case 4:
            ptr_4 = S_List_find_name(Flight_list->GOLD_USER,ptr->data.name);
            strcpy(ptr_4->data.name, name);
            S_List_File_print(Flight_list->GOLD_USER, GOLD_FILE);
            break;
        case 5:
            ptr_5 = S_List_find_name(Flight_list->PLATINUM_USER,ptr->data.name);
            strcpy(ptr_5->data.name, name);
            S_List_File_print(Flight_list->PLATINUM_USER, PLATINUM_FILE);
            break;
    }
    printf("用户名修改成功\n");
    sleep(2);
    return ;
}
void alter_password(U_node*ptr,FlightSystem *Flight_list)
{
    printf("请输入新密码\n");
    char password[64];
    scanf("%s", password);
    U_node * ptr_1;
    U_node * ptr_2;
    U_node * ptr_3;
    U_node * ptr_4;
    U_node * ptr_5;
    switch (ptr->data.grade)
    {
        case 1:
            ptr_1 = S_List_find_name(Flight_list->ADMIN_USER,ptr->data.name);
            strcpy(ptr_1->data.passwd, password);
            S_List_File_print(Flight_list->ADMIN_USER, ADMIN_FILE);
            break;
        case 2:
            ptr_2 = S_List_find_name(Flight_list->REGULAR_USER,ptr->data.name);
            strcpy(ptr_2->data.passwd, password);
            S_List_File_print(Flight_list->REGULAR_USER, REGULAR_FILE);
            break;
        case 3:
            ptr_3 = S_List_find_name(Flight_list->SILVER_USER,ptr->data.name);
            strcpy(ptr_3->data.passwd, password);
            S_List_File_print(Flight_list->SILVER_USER, SILVER_FILE);
            break;
        case 4:
            ptr_4 = S_List_find_name(Flight_list->GOLD_USER,ptr->data.name);
            strcpy(ptr_4->data.passwd, password);
            S_List_File_print(Flight_list->GOLD_USER, GOLD_FILE);
            break;
        case 5:
            ptr_5 = S_List_find_name(Flight_list->PLATINUM_USER,ptr->data.name);
            strcpy(ptr_5->data.passwd, password);
            S_List_File_print(Flight_list->PLATINUM_USER, PLATINUM_FILE);
            break;
    }
    printf("密码修改成功\n");
    sleep(2);
    return ;
}
